home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / ibus / engine.py < prev    next >
Text File  |  2009-11-05  |  6KB  |  205 lines

  1. # vim:set et sts=4 sw=4:
  2. #
  3. # ibus - The Input Bus
  4. #
  5. # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this program; if not, write to the
  19. # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20. # Boston, MA  02111-1307  USA
  21.  
  22. __all__ = (
  23.         "EngineBase",
  24.     )
  25.  
  26. import object
  27. import serializable
  28. import interface
  29.  
  30. class EngineBase(object.Object):
  31.     def __init__(self, bus, object_path):
  32.         super(EngineBase, self).__init__()
  33.         self.__proxy = EngineProxy (self, bus.get_dbusconn(), object_path)
  34.  
  35.     def process_key_event(self, keyval, keycode, state):
  36.         return False
  37.  
  38.     def focus_in(self):
  39.         pass
  40.  
  41.     def focus_out(self):
  42.         pass
  43.  
  44.     def set_cursor_location(self, x, y, w, h):
  45.         pass
  46.  
  47.     def set_capabilities(self, cap):
  48.         pass
  49.  
  50.     def reset(self):
  51.         pass
  52.  
  53.     def page_up(self):
  54.         pass
  55.  
  56.     def page_down(self):
  57.         pass
  58.  
  59.     def cursor_up(self):
  60.         pass
  61.  
  62.     def cursor_down(self):
  63.         pass
  64.  
  65.     def enable(self):
  66.         pass
  67.  
  68.     def disable(self):
  69.         pass
  70.  
  71.     def property_activate(self, prop_name, prop_state):
  72.         pass
  73.  
  74.     def property_show(self, prop_name):
  75.         pass
  76.  
  77.     def property_hide(self, prop_name):
  78.         pass
  79.  
  80.     def commit_text(self, text):
  81.         text = serializable.serialize_object(text)
  82.         return self.__proxy.CommitText(text)
  83.  
  84.     def forward_key_event(self, keyval, state):
  85.         return self.__proxy.ForwardKeyEvent(keyval, state)
  86.  
  87.     def update_preedit_text(self, text, cursor_pos, visible):
  88.         text = serializable.serialize_object(text)
  89.         return self.__proxy.UpdatePreeditText(text, cursor_pos, visible)
  90.  
  91.     def show_preedit_text(self):
  92.         return self.__proxy.ShowPreeditText()
  93.  
  94.     def hide_preedit_text(self):
  95.         return self.__proxy.HidePreeditText()
  96.  
  97.     def update_auxiliary_text(self, text, visible):
  98.         text = serializable.serialize_object(text)
  99.         return self.__proxy.UpdateAuxiliaryText(text, visible)
  100.  
  101.     def show_auxiliary_text(self):
  102.         return self.__proxy.ShowAuxiliaryText()
  103.  
  104.     def hide_auxiliary_text(self):
  105.         return self.__proxy.HideAuxiliaryText()
  106.  
  107.     def update_lookup_table(self, lookup_table, visible, just_current_page = False):
  108.         if just_current_page:
  109.             lookup_table = lookup_table.get_current_page_as_lookup_table()
  110.         dbus_values = serializable.serialize_object(lookup_table)
  111.         return self.__proxy.UpdateLookupTable(dbus_values, visible)
  112.  
  113.     def show_lookup_table(self):
  114.         return self.__proxy.ShowLookupTable()
  115.  
  116.     def hide_lookup_table(self):
  117.         return self.__proxy.HideLookupTable()
  118.  
  119.     def page_up_lookup_table(self):
  120.         return self.__proxy.PageUpLookupTable()
  121.  
  122.     def page_down_lookup_table(self):
  123.         return self.__proxy.PageDownLookupTable()
  124.  
  125.     def cursor_up_lookup_table(self):
  126.         return self.__proxy.CursorUpLookupTable()
  127.  
  128.     def cursor_down_lookup_table(self):
  129.         return self.__proxy.CursorDownLookupTable()
  130.  
  131.     def register_properties(self, props):
  132.         dbus_values = serializable.serialize_object(props)
  133.         return self.__proxy.RegisterProperties(dbus_values)
  134.  
  135.     def update_property(self, prop):
  136.         dbus_values = serializable.serialize_object(prop)
  137.         return self.__proxy.UpdateProperty(dbus_values)
  138.  
  139.     def get_dbus_object(self):
  140.         return self.__proxy
  141.  
  142.     def do_destroy(self):
  143.         self.__proxy = None
  144.         super(EngineBase,self).do_destroy()
  145.  
  146.  
  147. class EngineProxy(interface.IEngine):
  148.     def __init__(self, engine, conn, object_path):
  149.         super(EngineProxy, self).__init__(conn, object_path)
  150.         self.__engine = engine
  151.  
  152.     def ProcessKeyEvent(self, keyval, keycode, state):
  153.         return self.__engine.process_key_event(keyval, keycode, state)
  154.  
  155.     def FocusIn(self):
  156.         return self.__engine.focus_in()
  157.  
  158.     def FocusOut(self):
  159.         return self.__engine.focus_out()
  160.  
  161.     def SetCursorLocation(self, x, y, w, h):
  162.         return self.__engine.set_cursor_location(x, y, w, h)
  163.  
  164.     def SetCapabilities(self, caps):
  165.         return self.__engine.set_capabilities(caps)
  166.  
  167.     def Reset(self):
  168.         return self.__engine.reset()
  169.  
  170.     def PageUp(self):
  171.         return self.__engine.page_up()
  172.  
  173.     def PageDown(self):
  174.         return self.__engine.page_down()
  175.  
  176.     def CursorUp(self):
  177.         return self.__engine.cursor_up()
  178.  
  179.     def CursorDown(self):
  180.         return self.__engine.cursor_down()
  181.  
  182.     def CandidateClicked(self, index, button, state):
  183.         return self.__engine.candidate_clicked(index, button, state)
  184.  
  185.     def Enable(self):
  186.         return self.__engine.enable()
  187.  
  188.     def Disable(self):
  189.         return self.__engine.disable()
  190.  
  191.     def PropertyActivate(self, prop_name, prop_state):
  192.         return self.__engine.property_activate(prop_name, prop_state)
  193.  
  194.     def PropertyShow(self, prop_name):
  195.         return self.__engine.property_show(prop_name)
  196.  
  197.     def PropertyHide(self, prop_name):
  198.         return self.__engine.property_hide(prop_name)
  199.  
  200.     def Destroy(self):
  201.         self.__engine.destroy()
  202.         self.__engine = None
  203.         self.remove_from_connection ()
  204.  
  205.